import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration

def generate_launch_description():
    # 获取参数文件的路径
    deep_sort_ros = LaunchConfiguration('deep_sort_ros')
    deep_sort_yolo = LaunchConfiguration('deep_sort_yolo')

    declare_ros_param_file_cmd = DeclareLaunchArgument(
        'deep_sort_ros',
        default_value=os.path.join(
            get_package_share_directory('yolo_deep_sort'),
            'config',
            'deepsortros.yaml'),
        description='ROS 参数文件的完整路径。'
    )

    declare_network_param_file_cmd = DeclareLaunchArgument(
        'deep_sort_yolo',
        default_value=os.path.join(
            get_package_share_directory('yolo_deep_sort'),
            'config',
            'deepsortyolo.yaml'),
        description='网络参数文件的完整路径。'
    )

    # 启动 yolo_deep_sort 节点
    yolo_node = Node(
        package='yolo_deep_sort',
        executable='yolo_deep_sort_node',
        name='yolo_deep_sort_nodess',
        output='screen',
        parameters=[deep_sort_ros, deep_sort_yolo]
    )

    return LaunchDescription([
        declare_ros_param_file_cmd,
        declare_network_param_file_cmd,
        yolo_node,
    ])
